home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / SmallEiffel 0.3.3 / SmallEiffel 68k / lib_std / std_file_read_write.e < prev    next >
Encoding:
Text File  |  1996-06-13  |  1.3 KB  |  65 lines  |  [TEXT/EDIT]

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. -- Originally written by Emmanuel CECCHET --
  5. --
  6. class STD_FILE_READ_WRITE
  7. --
  8. inherit 
  9.    STD_FILE_READ
  10.       undefine connect_to, disconnect 
  11.       redefine read_character, end_of_input
  12.       end;
  13.    STD_FILE_WRITE
  14.       redefine connect_to, put_character
  15.       end;
  16.    
  17. creation {ANY}
  18.    connect_to
  19.    
  20. feature {ANY}
  21.    
  22.    connect_to(new_path: STRING) is
  23.       local
  24.      rewrite_fic : STD_FILE_WRITE ;
  25.       do
  26.      mode := "r+";
  27.      input_stream := fopen(new_path,mode);
  28.      if input_stream /= Void then
  29.         path := new_path;
  30.         output_stream := input_stream;
  31.      end;
  32.       end;
  33.    
  34.    read_character is
  35.       local
  36.      err: INTEGER;
  37.       do
  38.      err := fflush(output_stream);
  39.      last_character_memory := fgetc(input_stream);
  40.       end;
  41.    
  42.    put_character(c: CHARACTER) is
  43.       local
  44.      err: CHARACTER;
  45.      err2: INTEGER;
  46.       do
  47.      err2 := fflush(output_stream);
  48.      err := fputc(c,output_stream);
  49.      if err /= c then
  50.         std_error.put_string("Error while writing character."); 
  51.         crash;
  52.      end;
  53.       end;
  54.    
  55.    end_of_input: BOOLEAN is
  56.       local
  57.      err: INTEGER;
  58.       do
  59.      err := fflush(output_stream);
  60.      Result := feof(input_stream)
  61.       end;
  62.    
  63. end -- STD_FILE_READ_WRITE
  64.  
  65.